Skip to content

Deliveries: an overview of how deliveries went, from counters kept as they are recorded - #321

Merged
nambok merged 1 commit into
mainfrom
feat/delivery-analytics
Oct 27, 2026
Merged

nambok merged 1 commit into
mainfrom
feat/delivery-analytics

Conversation

@nambok

@nambok nambok commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

An analytics view for deliveries (webhooks in and out, relay, alerts, Jira, Slack/Teams, email): GET /api/deliveries/analytics returns hour or day buckets for 24h, 7d or 30d against the period before. It reads rollup counters written as each delivery is recorded, never the raw records, so it costs at most 60 item reads and covers 120 days while records are kept 14.

Pairs with the dashboard's Overview tab: CoderHelm/coderhelm#233.

Changes

  • common::deliveries_rollup (new). Hour items (kept 72 h) and day items (kept 120 days) on the settings table. deliveries::record now asks for the replaced item back and moves the rollups by the difference between the new record and the old one, so retries, redeliveries and racing writers count each delivery's final state exactly once. A delivery counts once it finishes. Counters per source and direction, and per webhook endpoint: handled, ignored and failed; retried, extra attempts and retried-then-fine; a latency histogram split by fine and failed (p50, p95 and p99 interpolated from it); failures by reason code and by event type. An endpoint streak item keeps failures in a row and the last failure and success.
  • Backfill. The first overview request counts records written before rollups existed (deliveries, alert events, the Jira event log), each marked rolled in a transaction that only succeeds where it isn't marked yet, so a record rewritten meanwhile is never counted twice. It runs for 5 seconds per request and resumes; the reply's backfill.complete says when it is done.
  • GET /api/deliveries/analytics (routes/deliveries_analytics.rs): period, source, status, endpoint. Admins, under the existing deliveries capability. A public API-key route with OpenAPI docs and examples (new "Deliveries" tag); docs/api/openapi.json regenerated. Endpoint metadata (address, on or off, why) is read from the WEBHOOK_ENDPOINT# items, never their secrets.
  • Hybrid: POST /hybrid/deliveries/rollups (signed) returns an install's relay and broker counters, and installs add them in. Self-hosted installs add the deliveries that reached no team.
  • Alerts and Jira count as they are written (alerts.rs uses the replaced item, since an SNS redelivery rewrites the same record).
  • List drill-in: GET /api/deliveries also takes until, endpoint and reason. since and until are compared as instants.
  • Rebased on Outbound webhooks: endpoints, a versioned event catalog, signed delivery with retries #306 (outbound webhooks, now on main): webhook deliveries count under source = webhook and per endpoint_id; their webhook_* reasons read in plain words.
  • Not in this PR: the Admin, Self-host relay and email-relay trends across installs. Self-host email: optional emails opt-in, a mail relay through CoderHelm, and a Self-host admin view #315 (the Admin, Self-host page) hasn't merged. Each install's relay counters are already kept under HYBRID#<install>, ready for that page.
  • docs/self-host/deliveries.md: an Overview section.
  • No table, GSI or infra changes; no AWS writes.

Verification

  • cargo fmt --check --all, cargo clippy --workspace --all-targets -- -D warnings, cargo test --workspace: common 1055, gateway 520 and worker 694 passed (after the rebase), 0 failed.
  • New Rust tests:
    • rollup writes and rewrites telescoping to the final state;
    • finished-only counting;
    • which buckets an old record still changes;
    • endpoint streaks;
    • histogram percentiles;
    • the exact update expression;
    • backfill counting each record once (including one rewritten mid-backfill), being idempotent and stopping at its deadline;
    • team isolation in the store and the aggregation;
    • a failed counter write never failing the record;
    • period plans for 24h, 7d and 30d with the period before;
    • week totals against the week before;
    • status, source and endpoint filters narrowing every number;
    • endpoint rows (off, deleted, streak);
    • empty periods reading as none, not 0%;
    • hybrid relay merging;
    • endpoint items read without secrets;
    • Jira log mapping;
    • until, endpoint and reason list filters.
  • OpenAPI completeness and permissions-table tests pass with the new route.
  • Customer-name grep on git diff origin/main prints nothing.

… they are recorded

Every delivery write now moves hour and day rollups by the difference from
the record it replaced, so retries and redeliveries count each delivery's
final state once. GET /api/deliveries/analytics reads at most 60 rollup
items for 24h, 7d or 30d against the period before: volume, success rate,
latency percentiles, retries, failures by reason, failing event types and
each webhook endpoint's rate, latency, streak and state. Older records are
counted once, lazily and resumably. Hybrid installs add the relay's counters
from the hosted side. The list also filters by until, endpoint and reason so
the overview can drill in.
@nambok
nambok force-pushed the feat/delivery-analytics branch from 2600ff4 to 782ceee Compare October 27, 2026 00:04
@nambok
nambok merged commit ead0a96 into main Oct 27, 2026
8 checks passed
@nambok
nambok deleted the feat/delivery-analytics branch October 27, 2026 01:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant